scorces = [90, 60, 80, 70, 60,78,60,90,22]
'''
列表：容器
下标，长度，切片
len()
循环：
    直接遍历
    下标遍历
常用操作：
    添加元素
        append:列表末尾追加一个元素
        insert：指定下标添加一个元素
        extend：合并列表
    删除元素
        remove
        del
        pop
        clear
    修改元素
        指定下标进行赋值
    查询
        循环
        in
        index
'''

print(scorces[2])
print(len(scorces))
print(scorces[0:5])
print(scorces[:5])
print(scorces[-3:])
print(scorces[::2])
sumScore = 0
for score in scorces:
    print(score)
    sumScore += score
print(sumScore)

for i in range(0,len(scorces)):
    print(i,scorces[i])

scorces.append(100)
print(scorces)
scorces.insert(2,50)
print(scorces)
#extend合并
alist=["a","b","c"]
blist=["d","e","f","a"]
alist.extend(blist)
print(alist)

scorces.remove(60)#根据值移除指定元素,只移除第一个指定值
print(scorces)
s = scorces.pop(0)#根据下标移除元素，并获取到该元素
print(s)
print(scorces)
del scorces[0]#根据下标移除元素
print(scorces)
# scorces.clear()
# print(scorces)
scorces[1]=99
print(scorces)

if 99 in scorces:
    print("99存在")

print(scorces.index(99))
# print(scorces.index(9911))#不存在报错
print(scorces.count(60))

#排序
scorces.sort()
print(scorces)
scorces.sort(reverse=True)#反转排序
print(scorces)

allNames=[["张三","李四","王五"],["小黑","小白"],["如花","小强","鬼见愁","鬼脚七"]]
i=1
for c in allNames:
    print("第{}班有{}人".format(i,len(c)))
    for v in c:
        print(v)
    i +=1
#编程实现一个元素全为数字的列表，求最大值、最小值
print(scorces[0])
print(scorces[-1])

scorces2 = [90, 60, 80, 70, 60,78,60,90,22]
min = scorces2[0]
max = scorces2[0]
for v in scorces2:
    if v < min:
        min = v
    if v > max:
        max = v
print(min,max)